{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "87e70f15",
   "metadata": {},
   "source": [
    "# 4. Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "464353df",
   "metadata": {},
   "outputs": [],
   "source": [
    "functions\n",
    "- types\n",
    "- scope\n",
    "- lambda"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "019ca66d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe511ead",
   "metadata": {},
   "outputs": [],
   "source": [
    "arguments and parameters\n",
    "\n",
    "- arguments\n",
    "- parameters\n",
    "- positional arguments\n",
    "- default arguments\n",
    "- arbitary arguments(args)\n",
    "- keyword arguments(kwargs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aea2f708",
   "metadata": {},
   "outputs": [],
   "source": [
    "built-in functions\n",
    "\n",
    "- abs,round,all,any,len\n",
    "- dir,enumerate,max,min\n",
    "- map\n",
    "- filter\n",
    "- reduce"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e095ffbe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0427a400",
   "metadata": {},
   "source": [
    "## Arguments and Parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a07a83f9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0fb9bf2c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "84c080c5",
   "metadata": {},
   "source": [
    "## Built-ins Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "996195da",
   "metadata": {},
   "outputs": [],
   "source": [
    "print()\n",
    "abs()\n",
    "round()\n",
    "all()\n",
    "any()\n",
    "dir()\n",
    "enumerate()\n",
    "Aggregation fuctions： sum(),max(),min()\n",
    "filter()\n",
    "map()\n",
    "reduce()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2170b37",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "084aae94",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1cf536d8",
   "metadata": {},
   "source": [
    "print()\n",
    "\n",
    "print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
    "\n",
    "Prints the values to a stream, or to sys.stdout by default."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2ad71269",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c160457",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b47db44d",
   "metadata": {},
   "source": [
    "### Aggregation Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e10e979d",
   "metadata": {},
   "outputs": [],
   "source": [
    "sum()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d78fa840",
   "metadata": {},
   "outputs": [],
   "source": [
    "max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5285a6c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8df57bd5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac6d1141",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "16287c14",
   "metadata": {},
   "source": [
    "### Map\n",
    "\n",
    "Map applies a function to all the items of an iterable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05a3c5bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "map()\n",
    "\n",
    "map(func, *iterables) --> map object"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd4e1252",
   "metadata": {},
   "source": [
    "### Filter\n",
    "\n",
    "The filter() method constructs an iterator from elements of an iterable for which a function returns true.\n",
    "\n",
    "`filter(function or None, iterable) --> filter object`"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "edf5b2f5",
   "metadata": {},
   "source": [
    "```python\n",
    "nums = [1, 2, 3, 4, 5, 6]\n",
    "\n",
    "evens = list(filter(lambda x:x % 2 == 0, nums))\n",
    "print(evens)  # [2, 4, 6]\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef82d7a7",
   "metadata": {},
   "source": [
    "### Reduce\n",
    "\n",
    "The reduce() function is for performing some computation on a list and returning the result.It applies a rolling computation to sequential pairs of values in a list.\n",
    "\n",
    "`reduce(function, sequence[, initial]) -> value`\n",
    "\n",
    "Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value.\n",
    "For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5).  If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
